package com.ljkj.lawyer.lawyer.dao;

import com.ljkj.lawyer.lawyer.entity.LawyerLitigationCaseEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface LawyerLitigationCaseDao extends JpaRepository<LawyerLitigationCaseEntity, Integer> {
    @Transactional
    @Modifying
    @Query(value = "update lawyer_litigation_case set is_last = 0 where id = ?1",nativeQuery = true)
    int updateAllCaseById(Integer id);

    @Query(value = "select * from lawyer_litigation_case where member_id =?1 and is_last = 1 order by create_time desc",nativeQuery = true)
    Page<LawyerLitigationCaseEntity> getCaseList(Integer memberId, Pageable pageable);

    @Query(value = "select * from lawyer_litigation_case where id =?1 and is_last = 1",nativeQuery = true)
    LawyerLitigationCaseEntity verifyId(Integer id);
}
